# Contributor: Anjandev Momi <anjan@momi.ca>
# Contributor: Guy Godfroy <guy.godfroy@gugod.fr>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=biboumi
pkgver=9.0
pkgrel=3
pkgdesc="XMPP to IRC gateway"
options="!check" # has no tests
url="https://biboumi.louiz.org/"
arch="all"
license="Zlib"
pkgusers="biboumi"
pkggroups="biboumi"
makedepends="cmake expat-dev gnu-libiconv-dev util-linux-dev libpq-dev
	libidn-dev udns-dev botan-dev libcap"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://git.louiz.org/biboumi/snapshot/biboumi-$pkgver.tar.xz
	$pkgname.initd
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-Wno-dev \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_BOTAN=True \
		-DWITHOUT_SYSTEMD=False \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
	setcap CAP_NET_BIND_SERVICE=+eip "$pkgdir"/usr/bin/biboumi

	install -Dm755 "$srcdir"/biboumi.initd "$pkgdir"/etc/init.d/biboumi
	install -Dm644 "$builddir"/conf/biboumi.cfg "$pkgdir"/etc/biboumi/biboumi.cfg.example
}

sha512sums="
cfaacd831b56031906922472275c55fd6f1a5307ebe54959d21e3799ad4612499e8beeb34e8736df9eabc9fec1a861d17567250d64f316ace47395fd6c8f3c18  biboumi-9.0.tar.xz
e13b30e67ac801b36f16f4dc453e1f41910c2f5828772af66af9e1e0cdd32a8209c907fdcd0e50afd691da0c8e2cad10803a51e681ce6bf86876439c968a0319  biboumi.initd
"
